<?php include _include(APP_PATH.'view/htm/header.inc.htm');?>

<!--{hook user_login_start.htm}-->

<div class="row">
    <div class="col-lg-5 offset-lg-3">
        <!--{hook user_login_card_before.htm}-->
        <div class="card card-body">
            <h4 class="card-title">
                绑定/新增
                <!--{hook user_login_title_after.htm}-->
            </h4>
            <form method="post" id="form">
                <p class="input-group">
                    <span class="input-group-addon"><i class="icon icon-user"></i></span>
                    <input type="text" class="form-control" placeholder="<?php echo lang('email'); ?>" id="email"
                           name="email">
                </p>
                <!--{hook user_login_email_after.htm}-->
                <p class="input-group">
                    <span class="input-group-addon"><i class="icon icon-lock"></i></span>
                    <input type="password" class="form-control" placeholder="<?php echo lang('password'); ?>"
                           id="password" name="password">
                </p>
                <input type="hidden" class="form-control" id="openid" value="<?php echo $openid ?>" name="openid">
                <!--{hook user_login_password_after.htm}-->
                <p class="text-right">
                    <button type="submit" class="btn btn-primary btn-block" id="submit"
                            data-loading-text="<?php echo lang('submiting'); ?>..."><?php echo lang('login'); ?></button>
                </p>
                <!--{hook user_login_submit_after.htm}-->
                <p class="text-right">
                    <a type="submit" class="btn btn-primary btn-block"
                       href="<?php echo url('wxlogin-auto')?>"
                       data-loading-text="<?php echo lang('submiting'); ?>..."><span class="icon-qq"></span> 一键自动登</a>
                </p>

            </form>
        </div>
        <!--{hook user_login_card_after.htm}-->
    </div>
</div>

<!--{hook user_login_end.htm}-->

<?php include _include(APP_PATH.'view/htm/footer.inc.htm');?>

<script src="view/js/md5.js"></script>

<script>
    var jform     = $('#form');
    var jsubmit   = $('#submit');
    var jemail    = $('#email');
    var jpassword = $('#password');
    var referer   = '<?php echo http_referer();?>';
    jform.on('submit', function () {
        jform.reset();
        jsubmit.button('loading');
        var postdata      = jform.serializeObject();
        postdata.password = $.md5(postdata.password);
        $.xpost(jform.attr('action'), postdata, function (code, message) {
            if ( code == 0 ) {
                $.alert(message);
                jsubmit.button(message).delay(3000).location('./');
                //jsubmit.button(message).delay(3000).location('./');
            } else if ( code == 'email' ) {
                jemail.alert(message).focus();
                jsubmit.button('reset');
            } else if ( code == 'password' ) {
                jpassword.alert(message).focus();
                jsubmit.button('reset');
            } else {
                alert(message);
                jsubmit.button('reset');
            }
        });
        return false;
    });

</script>

<!--{hook user_login_js.htm}-->